package com.leicx.guli.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author daxiong
 * @date 2022/4/6 下午10:10
 */
@Configuration
public class MyRedissonConfig {

    @Value("${spring.redis.host:192.168.31.10}")
    String redisHost;

    @Bean(destroyMethod = "shutdown")
    public RedissonClient getRedisson() {
        Config config = new Config();
        config.useSingleServer()
                // 可以用"rediss://"来启用SSL连接
                .setAddress("redis://" + redisHost + ":6379");
        return Redisson.create(config);
    }
}
